<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta content="telephone=no" name="format-detection">
    <title>完善资料 2/4</title>
    <script src="../../../js/jquery-1.8.3.min.js"></script>
    <script src="../../../js/mobile.js"></script>
    <!-- 根据额外需求引用fix.js -->
    <script src="./js/fix.js"></script>

    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/pefect_info.css">
    <script src="./js/datePicker.js"></script>
    <link rel="stylesheet" href="./css/ksd.css">
</head>
<script>
    $(function () {
        var myDate = new Date(),
            year = myDate.getFullYear(),
            month = myDate.getMonth() + 1,
            date = myDate.getDate(),
            maxDate = year + 1 + "-" + month + "-" + date,
            calendar = new datePicker();
        $(document).ready(function name() {
            var h = $(document).height(); //页面总高度
            var h1 = $(window).height(); //页面显示区域高度
            if (h <= h1) {
                // alert("页面小于一屏");
                $(".btn").css("bottom", "3%");
            }
            $("#date_yy_show").text(year);
            $("#date_mm_show").text(month);
            $("#date_dd_show").text(date);
            $("#demo1").trigger("click"); //默认展开时间

        });
        calendar.init({
            'trigger': '#demo1',
            /*按钮选择器，用于触发弹出插件*/
            'type': 'date',
            /*模式：date日期；datetime日期时间；time时间；ym年月；*/
            'minDate': '1900-1-1',
            /*最小日期*/
            'maxDate': maxDate,
            // 'maxDate': '2100-1-1',
            /*最大日期*/
            'onSubmit': function () { /*确认时触发事件*/
                var theSelectData = calendar.value;
            },
            'onClose': function () { /*取消时触发事件*/ }
        });
        var storage = window.localStorage;
        var birth_date = "";
        $("#next").on("click", function () {
            birth_date = birth_date + $.trim($("#birth_date span").eq(0).text()) + "-";
            birth_date = birth_date + $.trim($("#birth_date span").eq(1).text()) + "-";
            birth_date = birth_date + $.trim($("#birth_date span").eq(2).text());
            var date = new Date();
            var birthday = birth_date;
            var startDate = new Date(birthday);
            var newDate = date.getTime() - startDate.getTime();
            // 向下取整  例如 10岁 20天 会计算成 10岁, 如果要向上取整 计算成11岁，把floor替换成 ceil
            var age = Math.ceil(newDate / 1000 / 60 / 60 / 24 / 365);
            if (storage.length != 0) {
                var person = JSON.parse(storage.person_info);
                person.age = age;
                storage.person_info = JSON.stringify(person);
                window.location.href = 'perfect_info3.html'
            } else {
                window.location.href = 'homepagehtml.html'
            }
        });
        $(".footer").click(function () {
            if ($(".cell-right span").hasClass("switch-off")) {
                setCookie("sex", "1", 30);
                alert(getCookie("sex"))
            } else {
                setCookie("sex", "0", 30);
                alert(getCookie("sex"))
            }
            var height = $(".rval").text();
            setCookie("height", height, 30);
            alert(getCookie("height"))
        })
    })

    function setCookie(c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
    }

    function getCookie(c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1
                c_end = document.cookie.indexOf(";", c_start)
                if (c_end == -1)
                    c_end = document.cookie.length
                return unescape(document.cookie.substring(c_start, c_end))
            }
        }
        return "";
    }
</script>

<body>
    <div class="back" style="background-color: rgb(245,245,245)">
        <div class="upcore-navbar">
            <span class="upcore-navbar-icon-left" onclick="history.back(-1)"></span>
            <span class="upcore-navbar-name-span">完善资料2/4</span>
            <br style="clear:both">
        </div>
        <div class="cont cont1">
            <p class="title_font Regular">出生日期</p>
        </div>
        <div id="date_show" class="date_show Light">
            <div id="birth_date" style="margin-bottom: 0.47rem">
                <span id="date_yy_show" class="Medium">1992</span>年
                <span id="date_mm_show" class="Medium">10</span>月
                <span id="date_dd_show" class="Medium">21</span>日
            </div>
        </div>
        <article></article>
        <div class="date_show_choose"></div>
        <div style="width:100%;height: 2.5rem;">
            <input id="demo1" class="none">
            <script>

            </script>
        </div>
        <button id="next" class="btn" style="bottom: 3%;">下一步</button>
    </div>
</body>

</html>